// Package _6_ReverseLinkList
// Date        : 2022/12/6 11:50
// Version     : 1.0.0
// Author      : 代码小学生王木木
// Email       : 18574945291@163.com
// Description : https://leetcode.cn/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/?favorite=xb9nqhhg
package _6_ReverseLinkList

//Definition for singly-linked list.
type ListNode struct {
	Val  int
	Next *ListNode
}

func reversePrint(head *ListNode) []int {
	if head == nil {
		return nil
	}
	var ans []int
	p := head
	for p != nil {
		ans = append(ans, p.Val)
		p = p.Next
	}
	arrLen := len(ans)
	for i := 0; i < arrLen/2; i++ {
		ans[i], ans[arrLen-i-1] = ans[arrLen-i-1], ans[i]
	}

	return ans
}

//func reversePrint(head *ListNode) []int {
//	var ans []int
//
//	var process func(node *ListNode)
//	process = func(node *ListNode) {
//
//	}
//	process(head)
//	return ans
//}
